package com.example.es.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.junit.Test;

import java.io.IOException;
import java.util.Map;

/**
 * @description:  id查询
 * @author: ruoan
 * @date: 2020/10/11 11:57
 */
public class EsRestHighLevelClientTest12 {

    private RestHighLevelClient client= EsRestHighLevelClient.getClient();
    ObjectMapper mapper = new ObjectMapper();
    String index = "sms-logs-index";
    String type="sms-logs-type";

    @Test
    public void id() throws IOException {


        GetRequest getRequest = new GetRequest(index,type,"2");
        GetResponse documentFields = client.get(getRequest, RequestOptions.DEFAULT);
        Map<String, Object> sourceAsMap =
                documentFields.getSourceAsMap();
        System.out.println(sourceAsMap);



    }







}